SIR Model¶
In this tutorial, we will learn how to use the SIR model.
In [1]:
Copied!
import plotly.express as px
from hamilflow.models.sir import SIR
import plotly.express as px
from hamilflow.models.sir import SIR
Model¶
In [2]:
Copied!
sir_1 = SIR(
system={
"beta": 0.03,
"alpha": 0.1,
"delta_t": 0.1,
},
initial_condition={
"susceptible_0": 999,
"infected_0": 1,
"recovered_0": 0,
},
)
sir_1 = SIR(
system={
"beta": 0.03,
"alpha": 0.1,
"delta_t": 0.1,
},
initial_condition={
"susceptible_0": 999,
"infected_0": 1,
"recovered_0": 0,
},
)
In [3]:
Copied!
n_steps = 100
sir_1_results = sir_1.generate_from(n_steps=n_steps)
sir_1_results.head()
n_steps = 100
sir_1_results = sir_1.generate_from(n_steps=n_steps)
sir_1_results.head()
Out[3]:
| t | S | I | R | |
|---|---|---|---|---|
| 0 | 0.00 | 999 | 1 | 0 |
| 1 | 0.01 | 999 | 1 | 0 |
| 2 | 0.02 | 997 | 3 | 0 |
| 3 | 0.03 | 989 | 11 | 0 |
| 4 | 0.04 | 957 | 43 | 0 |
In [4]:
Copied!
px.line(
sir_1_results,
x="t",
y=["S", "I", "R"],
)
px.line(
sir_1_results,
x="t",
y=["S", "I", "R"],
)
In [ ]:
Copied!